﻿#region Usings

using System.Data.Entity;
using System.Data.Entity.ModelConfiguration.Conventions;
using Rail.Net.Core.Interfaces.Data;
using Rail.Net.Core.Model;
using Rail.Net.Data.Configuration;

#endregion

namespace Rail.Net.Data
{
    public class DataContext : DbContext
    {
        public DbSet<Ru> Rus { get; set; }

        public DbSet<Station> Stations { get; set; }

        public DbSet<Relation> Relations { get; set; }

        public DbSet<RelationDescription> RelationDescriptions { get; set; }

        public DbSet<RelationRu> RelationRus { get; set; }

        public DbSet<Distance> Distances { get; set; }

        public DbSet<PriceDistance> PriceDistances { get; set; }

        public DbSet<PriceSerial> PriceSerials { get; set; }

        public DbSet<PriceDomestic> PriceDomestics { get; set; }

        public DbSet<ContengentTrainLabel> ContengentTrainLabels { get; set; }

        public DbSet<ContengentTrainNumber> ContengentTrainNumbers { get; set; }

        public DbSet<GlobalTrainLabel> GlobalTrainLabels { get; set; }

        public DbSet<GlobalTrainNumber> GlobalTrainNumbers { get; set; }

        public DbSet<ReservableTrainLabel> ReservableTrainLabels { get; set; }

        public DbSet<ReservableTrainNumber> ReservableTrainNumbers { get; set; }

        public DbSet<VirtualRuTrainNumber> VirtualRuTrainNumbers { get; set; }

        public DbSet<Tariff> Tariffs { get; set; }

        public DbSet<Administration> Administrations { get; set; }

        public DbSet<PaymentOption> PaymentOptions { get; set; }

        public DbSet<TravelerCombination> TravelerCombinations { get; set; }

        public DbSet<Traveler> Travelers { get; set; }

        public DbSet<DiscountOption> DiscountOptions { get; set; }


        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Configurations.Add(new RuMap());
            modelBuilder.Configurations.Add(new StationMap());
            modelBuilder.Configurations.Add(new DistanceMap());
            modelBuilder.Configurations.Add(new RelationMap());
            modelBuilder.Configurations.Add(new RelationDescriptionMap());
            modelBuilder.Configurations.Add(new RelationRuMap());
            modelBuilder.Configurations.Add(new PriceDomesticMap());
            modelBuilder.Configurations.Add(new PriceSerialMap());
            modelBuilder.Configurations.Add(new PriceDistanceMap());
            modelBuilder.Configurations.Add(new ContengentTrainLabelMap());
            modelBuilder.Configurations.Add(new ContengentTrainNumberMap());
            modelBuilder.Configurations.Add(new GlobalTrainLabelMap());
            modelBuilder.Configurations.Add(new GlobalTrainNumberMap());
            modelBuilder.Configurations.Add(new ReservableTrainLabelMap());
            modelBuilder.Configurations.Add(new ReservableTrainNumberMap());
            modelBuilder.Configurations.Add(new VirtualRuTrainNumberMap());
            modelBuilder.Configurations.Add(new TariffMap());
            modelBuilder.Configurations.Add(new AdministrationMap());
            modelBuilder.Configurations.Add(new PaymentOptionMap());
            modelBuilder.Configurations.Add(new TravelerCombinationMap());
            modelBuilder.Configurations.Add(new TravelerMap());
            modelBuilder.Configurations.Add(new DiscountOptionMap());


            
            modelBuilder.Conventions.Remove<OneToManyCascadeDeleteConvention>();

            base.OnModelCreating(modelBuilder);
        }
    }
}